<?php
include '../../init.php';

include DIR_CORE.'mysql.php';

//var_dump($_POST);

$type_id = s($_POST['type']);
$question = s($_POST['question']);
$A = s($_POST['A']);
$B = s($_POST['B']);
$C = s($_POST['C']);
$D = s($_POST['D']);
$a = s($_POST['answer']);
$answer = strtoupper(str_replace('，', ',', $a));
$time = time();

//先验证是否重复
$sql = "select * from multiple where question = '$question'";
$res = mysqli_query($link, $sql);
if (mysqli_affected_rows($link)>=1) {
    echo '<h2 style="color:red;font-weight:bold;">题目已存在！</h2>';
    die;
}

$asql = "insert into multiple values(null,'$type_id','$question','$A','$B','$C','$D','$answer','$time')";
//echo $asql;

$result = mysqli_query($link, $asql);
if ($result) {
    echo '<h2 style="color:green;font-weight:bold;">添加成功</h2>';
} else {
    echo '<h2 style="color:green;font-weight:red;">添加失败</h2>';
}
